﻿using System;
using System.ServiceProcess;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using Neo4jRestSharp.Neo4jObjectServices;
using Neo4jRestSharp.Neo4jRestServices;
using NUnit.Framework;

namespace Neo4jRestSharp.Test.Neo4jObjectServices
{
    [TestFixture]
    public class NodeObjectTests : BaseServicesTest
    {
        private readonly Uri neo4jRestUri = new Uri("http://localhost:9999/");
        private const string ROOT_NODE = "http://localhost:9999/node/0";
        private const string ROOT_INDEX = "http://localhost:9999/index";

        [Test]
        public void GetRoodNode()
        {
			NodeObjectServices nodeObjectServices = ServicesFactory.ObjectServices(neo4jRestUri);
            RootNode rootNode = nodeObjectServices.GetRootNode();
            Assert.IsNotNull(rootNode);
            Assert.AreEqual(rootNode.Id, 0);
            Assert.IsFalse(string.IsNullOrWhiteSpace(rootNode.Index));
            Assert.AreEqual(rootNode.Index, ROOT_INDEX);
            Assert.IsFalse(string.IsNullOrWhiteSpace(rootNode.Uri));
            Assert.AreEqual(rootNode.Uri, ROOT_NODE);
        }

        [Test]
        public void CreateNode()
        {
			NodeObjectServices nodeObjectServices = ServicesFactory.ObjectServices(neo4jRestUri);

			//create node, then get node
            Person morpheus = this.CreatePerson<Person>(NODE1_NAME, NODE1_TITLE);

            Assert.IsNotNull(morpheus);
            Assert.Greater(morpheus.Id, 0);

        	Person morpheus2 = nodeObjectServices.GetNode<Person>(morpheus.Id);
            Assert.AreEqual(morpheus.Name, morpheus2.Name);
            Assert.AreEqual(morpheus.Title, morpheus2.Title);
        	Assert.AreEqual(morpheus.Id, morpheus2.Id);
        }

        [Test]
        public void GetNode()
        {
			NodeObjectServices nodeObjectServices = ServicesFactory.ObjectServices(neo4jRestUri);

            //create node, then get node
            MatrixPerson morpheus = this.CreatePerson<MatrixPerson>(NODE1_NAME, NODE1_TITLE);

            Person morpheus3 = nodeObjectServices.GetNode<Person>(morpheus.Id);
            Assert.IsNotNull(morpheus3);
            Assert.AreEqual(morpheus.Id, morpheus3.Id);
            Assert.AreEqual(morpheus.Name, morpheus3.Name);
            Assert.AreEqual(morpheus.Title, morpheus3.Title);
			Assert.AreEqual(morpheus.SelfUri, morpheus3.SelfUri);
        }

        [Test]
        public void SetNodeProperties()
        {
			NodeObjectServices nodeObjectServices = ServicesFactory.ObjectServices(neo4jRestUri);

            //create node, then get node
            MatrixPerson morpheus = this.CreatePerson<MatrixPerson>(NODE1_NAME, NODE1_TITLE);

            //validate node against its stored properties
            ValidatePropertiesOnNode(morpheus);

            //change title and validate
            morpheus.Title = NODE1_TITLE_2;
            morpheus.IsAgent = true;
            nodeObjectServices.SetNodeProperties(morpheus);

            MatrixPerson morpheus2 = nodeObjectServices.GetNode<MatrixPerson>(morpheus.Id);
            Assert.IsNotNull(morpheus2);
            Assert.AreEqual(morpheus.Id, morpheus2.Id);
            Assert.AreEqual(morpheus.Name, morpheus2.Name);
            Assert.AreEqual(morpheus.Title, morpheus2.Title);
            Assert.AreEqual(morpheus.IsHuman, morpheus2.IsHuman);
            Assert.AreEqual(morpheus.IsAgent, morpheus2.IsAgent);
        }

        [Test]
        public void GetNodeProperties()
        {
			NodeObjectServices nodeObjectServices = ServicesFactory.ObjectServices(neo4jRestUri);

            //create node, then get node
            MatrixPerson morpheus = this.CreatePerson<MatrixPerson>(NODE1_NAME, NODE1_TITLE);

            //validate node against its stored properties
            ValidatePropertiesOnNode(morpheus);
        }

        [Test]
        public void RemoveNodePropertiesById()
        {
			NodeObjectServices nodeObjectServices = ServicesFactory.ObjectServices(neo4jRestUri);

            //create node, then get node
            MatrixPerson morpheus = this.CreatePerson<MatrixPerson>(NODE1_NAME, NODE1_TITLE);

            //validate node against its stored properties
            ValidatePropertiesOnNode(morpheus);

            //now clear properties and validate they are cleared
            nodeObjectServices.RemoveNodeProperties(morpheus.Id);
            MatrixPerson morpheus2 = nodeObjectServices.GetNode<MatrixPerson>(morpheus.Id);
            Assert.IsNotNull(morpheus2);
            Assert.AreEqual(morpheus2.Id, morpheus.Id);
            Assert.IsTrue(string.IsNullOrWhiteSpace(morpheus2.Name));
            Assert.IsTrue(string.IsNullOrWhiteSpace(morpheus2.Title));
            Assert.IsFalse(morpheus2.IsHuman);
            Assert.IsFalse(morpheus2.IsAgent);
        }

        [Test]
        public void RemoveNodePropertiesByNode()
        {
			NodeObjectServices nodeObjectServices = ServicesFactory.ObjectServices(neo4jRestUri);

            //create node, then get node
            MatrixPerson morpheus = this.CreatePerson<MatrixPerson>(NODE1_NAME, NODE1_TITLE);

            //validate node against its stored properties
            ValidatePropertiesOnNode(morpheus);

            //now clear properties and validate they are cleared
            nodeObjectServices.RemoveNodeProperties(morpheus);
            Assert.IsTrue(string.IsNullOrWhiteSpace(morpheus.Name));
            Assert.IsTrue(string.IsNullOrWhiteSpace(morpheus.Title));
            Assert.IsFalse(morpheus.IsHuman);
            Assert.IsFalse(morpheus.IsAgent);

            MatrixPerson morpheus2 = nodeObjectServices.GetNode<MatrixPerson>(morpheus.Id);
            Assert.IsNotNull(morpheus2);
            Assert.AreEqual(morpheus.Id, morpheus2.Id);
            Assert.IsTrue(string.IsNullOrWhiteSpace(morpheus2.Name));
            Assert.IsTrue(string.IsNullOrWhiteSpace(morpheus2.Title));
            Assert.IsFalse(morpheus2.IsHuman);
            Assert.IsFalse(morpheus2.IsAgent);
        }

        [Test]
        [Ignore]
        public void SetNodeProperty()
        {
			NodeObjectServices nodeObjectServices = ServicesFactory.ObjectServices(neo4jRestUri);

            //create node, then get node
            MatrixPerson morpheus = this.CreatePerson<MatrixPerson>(NODE1_NAME, NODE1_TITLE);

            //validate node against its stored properties
            ValidatePropertiesOnNode(morpheus);

            //now change a property
            nodeObjectServices.SetNodeProperty(morpheus.Id, Person.TITLE, NODE1_TITLE_2);
            morpheus.Title = NODE1_TITLE_2;

            //get person and validate properties are correct
            MatrixPerson morpheus2 = nodeObjectServices.GetNode<MatrixPerson>(morpheus.Id);
            Assert.IsNotNull(morpheus2);
            Assert.AreEqual(morpheus.Id, morpheus2.Id);
            Assert.AreEqual(morpheus.Name, morpheus2.Name);
            Assert.AreEqual(morpheus.Title, morpheus2.Title);
            Assert.AreEqual(morpheus2.Title, NODE1_TITLE_2);
        }

        [Test]
        public void GetNodeProperty()
        {
			NodeObjectServices nodeObjectServices = ServicesFactory.ObjectServices(neo4jRestUri);

            //create node, then get node
            MatrixPerson morpheus = this.CreatePerson<MatrixPerson>(NODE1_NAME, NODE1_TITLE);

            //validate node against its stored properties
            ValidatePropertiesOnNode(morpheus);

            string name = nodeObjectServices.GetNodeProperty(morpheus.Id, MatrixPerson.NAME);
            string title = nodeObjectServices.GetNodeProperty(morpheus.Id, MatrixPerson.TITLE);
            Assert.AreEqual(name, morpheus.Name);
            Assert.AreEqual(title, morpheus.Title);
        }

        [Test]
        public void RemoveNodeProperty()
        {
			NodeObjectServices nodeObjectServices = ServicesFactory.ObjectServices(neo4jRestUri);

            //create node, then get node
            MatrixPerson morpheus = this.CreatePerson<MatrixPerson>(NODE1_NAME, NODE1_TITLE);

            //validate node against its stored properties
            ValidatePropertiesOnNode(morpheus);

            nodeObjectServices.RemoveNodeProperty(morpheus.Id, MatrixPerson.TITLE);
            MatrixPerson morpheus2 = nodeObjectServices.GetNode<MatrixPerson>(morpheus.Id);
            Assert.IsNotNull(morpheus2);
            Assert.IsFalse(string.IsNullOrWhiteSpace(morpheus2.Name));
            Assert.IsTrue(string.IsNullOrWhiteSpace(morpheus2.Title));

            nodeObjectServices.RemoveNodeProperty(morpheus.Id, MatrixPerson.NAME);
            morpheus2 = nodeObjectServices.GetNode<MatrixPerson>(morpheus.Id);
            Assert.IsNotNull(morpheus2);
            Assert.IsTrue(string.IsNullOrWhiteSpace(morpheus2.Name));
            Assert.IsTrue(string.IsNullOrWhiteSpace(morpheus2.Title));
        }

        [Test]
		[ExpectedException(typeof(Neo4jRestException))]
        public void RemoveNode()
        {
			NodeObjectServices nodeObjectServices = ServicesFactory.ObjectServices(neo4jRestUri);

            //create node, then get node
            MatrixPerson morpheus = this.CreatePerson<MatrixPerson>(NODE1_NAME, NODE1_TITLE);

            //validate node against its stored properties
            ValidatePropertiesOnNode(morpheus);
        	int id = morpheus.Id;

            nodeObjectServices.DeleteNode(morpheus);

			//Eat it, eat it, eat it, eat it...If it's gettin' cold, reheat it
            nodeObjectServices.GetNode<MatrixPerson>(id);
        }       

		[Test]
		public void CreateRelationship()
		{
			NodeObjectServices nodeObjectServices = ServicesFactory.ObjectServices(neo4jRestUri);

			//create 2 nodes, then get both nodes
			MatrixPerson morpheus = this.CreatePerson<MatrixPerson>(NODE1_NAME, NODE1_TITLE);
			MatrixPerson neo = this.CreatePerson<MatrixPerson>(NODE2_NAME, NODE2_TITLE);

			Relationship relationship = morpheus.CreateRelationshipTo(neo, RelationshipType.Knows);
			var rels = neo.GetRelationships(RelationshipDirection.In);
			Assert.AreEqual(rels.Count(), 1);
			Assert.AreEqual(rels.First().Id, relationship.Id);

			rels = morpheus.GetRelationships(RelationshipDirection.Out);
			Assert.AreEqual(rels.Count(), 1);
			Assert.AreEqual(rels.First().Id, relationship.Id);			
		}

		[Test]		
		public void SetRelationshipProperties()
		{
			NodeObjectServices nodeObjectServices = ServicesFactory.ObjectServices(neo4jRestUri);

			MatrixPerson morpheus;
			MatrixPerson neo;
			CreateTwoPeopleWithRelationships(out morpheus, out neo);

			System.Threading.Thread.Sleep(1000);
			DateTime now = DateTime.Now;

			var rels = morpheus.GetRelationships(RelationshipDirection.Out);
			foreach (var relationship in rels)
			{
				relationship.SetProperty("isBadAss", "true");
				relationship.SetProperty("date", now.ToString());
				relationship.SaveProperties();
			}

			MatrixPerson morpheus2 = nodeObjectServices.GetNode<MatrixPerson>(morpheus.Id);
			rels = morpheus2.GetRelationships(RelationshipDirection.Out);
			foreach (var relationship in rels)
			{
				Assert.AreEqual(relationship.GetProperties().Count(), 3);
				Assert.AreEqual(relationship.GetProperty("isBadAss"), "true");
				Assert.AreEqual(relationship.GetProperty("date"), now.ToString());
				Assert.AreEqual(relationship.GetProperty("action"), "Recruited Neo");
			}
		}

		[Test]
		public void GetRelationshipProperties()
		{
			NodeObjectServices nodeObjectServices = ServicesFactory.ObjectServices(neo4jRestUri);

			MatrixPerson morpheus;
			MatrixPerson neo;
			CreateTwoPeopleWithRelationships(out morpheus, out neo);

			//validate props on morpheus
			foreach (var rel in morpheus.GetRelationships())
			{
				//store off props
				Dictionary<string, string> propCach = new Dictionary<string, string>();
				foreach (var kvp in rel.GetProperties())
				{
					propCach.Add(kvp.Key, kvp.Value);
				}

				//do this to clear props internally
				rel.SaveProperties();
				//now go get rels
				nodeObjectServices.GetRelationshipProperties(rel);

				foreach (var kvp in propCach)
				{
					string val = rel.GetProperty(kvp.Key);
					Assert.AreEqual(val, kvp.Value);
				}
			}

			//validate props on neo
			foreach (var rel in neo.GetRelationships())
			{
				//store off props
				Dictionary<string, string> propCach = new Dictionary<string, string>();
				foreach (var kvp in rel.GetProperties())
				{
					propCach.Add(kvp.Key, kvp.Value);
				}

				//do this to clear props internally
				rel.SaveProperties();
				//now go get rels
				nodeObjectServices.GetRelationshipProperties(rel);

				foreach (var kvp in propCach)
				{
					string val = rel.GetProperty(kvp.Key);
					Assert.AreEqual(val, kvp.Value);
				}
			}
		}

		[Test]
		public void RemoveRelationshipProperties()
		{
			//****Note...this test seems to fail (50%) when run in release build, 
			//		but I cant get it to happen in debug build, 
			//		or launch the debugger when it fails in release build

			NodeObjectServices nodeObjectServices = ServicesFactory.ObjectServices(neo4jRestUri);

			MatrixPerson morpheus;
			MatrixPerson neo;
			CreateTwoPeopleWithRelationships(out morpheus, out neo);

			//validate props on morpheus
			foreach (var rel in morpheus.GetRelationships())
			{
				//store off props
				Dictionary<string, string> propCach = new Dictionary<string, string>();
				foreach (var kvp in rel.GetProperties())
				{
					propCach.Add(kvp.Key, kvp.Value);
				}

				//do this to clear props internally
				rel.SaveProperties();
				//now go get rels and validate
				nodeObjectServices.GetRelationshipProperties(rel);
				foreach (var kvp in propCach)
				{
					string val = rel.GetProperty(kvp.Key);
					Assert.AreEqual(val, kvp.Value);
				}

				//remove props on relationships and validate
				nodeObjectServices.RemoveRelationshipProperties(rel);
				nodeObjectServices.GetRelationshipProperties(rel);
				Assert.AreEqual(rel.GetProperties().Count(), 0);				
			}

			//validate props on neo
			foreach (var rel in neo.GetRelationships())
			{
				//store off props
				Dictionary<string, string> propCach = new Dictionary<string, string>();
				foreach (var kvp in rel.GetProperties())
				{
					propCach.Add(kvp.Key, kvp.Value);
				}

				//do this to clear props internally
				rel.SaveProperties();
				//now go get rels
				nodeObjectServices.GetRelationshipProperties(rel);
				foreach (var kvp in propCach)
				{
					string val = rel.GetProperty(kvp.Key);
					Assert.AreEqual(val, kvp.Value);
				}

				//remove props on relationships and validate
				nodeObjectServices.RemoveRelationshipProperties(rel);
				nodeObjectServices.GetRelationshipProperties(rel);
				Assert.AreEqual(rel.GetProperties().Count(), 0);				
			}
		}

		[Test]
		[Ignore]
		public void SetRelationshipProperty()
		{
			throw new NotImplementedException();
		}

		[Test]
		[Ignore]
		public void GetRelationshipProperty()
		{
			throw new NotImplementedException();
		}

		[Test]
		[Ignore]
		public void RemoveRelationshipProperty()
		{
			throw new NotImplementedException();
		}

		[Test]
		public void RemoveRelationship()
		{
			NodeObjectServices nodeObjectServices = ServicesFactory.ObjectServices(neo4jRestUri);

			MatrixPerson morpheus;
			MatrixPerson neo;
			CreateTwoPeopleWithRelationships(out morpheus, out neo);

			//now spin through and delete all relationships on morpheus			
			int count = 2;
			string relId = null;
			var relationships = nodeObjectServices.GetRelationshipsOnNode(morpheus.Id, RelationshipDirection.All, Enumerable.Empty<string>());
			while (count > 0)
			{
				Assert.AreEqual(relationships.Count(), count--);
				var rel = relationships.ElementAt(0);

			    //validate we just deleted the correct relationship id
			    if (relId != null)
			    {
			        //make sure last relationship id is NOT in return list of ids
					foreach (var relationship in relationships)
			        {
						Assert.AreNotEqual(relId, rel.SelfUri.Segments[2]);
			        }
			    }

			    //delete the relationhsip				
				relId = rel.SelfUri.Segments[2];
				nodeObjectServices.RemoveRelationship(rel);

			    //now go get all relationships for morpheus
				relationships = nodeObjectServices.GetRelationshipsOnNode(morpheus.Id, RelationshipDirection.All, Enumerable.Empty<string>());
			}

			relationships = nodeObjectServices.GetRelationshipsOnNode(morpheus.Id, RelationshipDirection.All, Enumerable.Empty<string>());
			Assert.AreEqual(relationships.Count(), 0);
		}

		[Test]
		public void GetRelationshipsOnNode()
		{
			NodeObjectServices nodeObjectServices = ServicesFactory.ObjectServices(neo4jRestUri);

			MatrixPerson morpheus;
			MatrixPerson neo;
			CreateTwoPeopleWithRelationships(out morpheus, out neo);			

			//get ids of two folks
			int[] ids = new int[] { morpheus.Id, neo.Id };

			//TEST MATRIX (ha ha ha)            
			IEnumerable<Relationship> relationships = null;
			//test for each type of RelationshipDirection            
			foreach (var relDir in Enums.Get<RelationshipDirection>())
			{
				//Test for all relationship types via empty types enum
				//var relTypes = Enumerable.Empty<RelationshipType>();
				//foreach (int startId in ids)
				//{
				//    json = restServices.GetRelationshipsOnNode(startId, relDir, relTypes.Select(e => e.ToString()));
				//    ValidateRelationshipJson(json, startId, ids, relDir, relTypes);
				//}

				//Test for all relationship types
				var relTypes = Enums.Get<RelationshipType>();
				foreach (int startId in ids)
				{
					relationships = nodeObjectServices.GetRelationshipsOnNode(startId, relDir, relTypes.Select(e => e.ToString()));
					ValidateRelationshipJson(relationships, startId, ids, relDir, relTypes);
				}

				//Test for all relationship types Knows, Recruited
				relTypes = Enums.Get<RelationshipType>().Where(rt => rt == RelationshipType.Knows || rt == RelationshipType.Recruited);
				foreach (int startId in ids)
				{
					relationships = nodeObjectServices.GetRelationshipsOnNode(startId, relDir, relTypes.Select(e => e.ToString()));
					ValidateRelationshipJson(relationships, startId, ids, relDir, relTypes);
				}

				//Test for all relationship types Knows, WorksFor
				relTypes = Enums.Get<RelationshipType>().Where(rt => rt == RelationshipType.Knows || rt == RelationshipType.WorksFor);
				foreach (int startId in ids)
				{
					relationships = nodeObjectServices.GetRelationshipsOnNode(startId, relDir, relTypes.Select(e => e.ToString()));
					ValidateRelationshipJson(relationships, startId, ids, relDir, relTypes);
				}

				//Test for all relationship types Recruited, WorksFor
				relTypes = Enums.Get<RelationshipType>().Where(rt => rt == RelationshipType.Recruited || rt == RelationshipType.WorksFor);
				foreach (int startId in ids)
				{
					relationships = nodeObjectServices.GetRelationshipsOnNode(startId, relDir, relTypes.Select(e => e.ToString()));
					ValidateRelationshipJson(relationships, startId, ids, relDir, relTypes);
				}

				foreach (var relationshipType in Enums.Get<RelationshipType>())
				{
					//Test single relationship type
					foreach (int startId in ids)
					{
						relationships = nodeObjectServices.GetRelationshipsOnNode(startId, relDir, relTypes.Select(e => e.ToString()));
						ValidateRelationshipJson(relationships, startId, ids, relDir, relTypes);
					}
				}
			}
		}



		private void CreateTwoPeopleWithRelationships(out MatrixPerson morpheus, out MatrixPerson neo)
		{
			NodeObjectServices nodeObjectServices = ServicesFactory.ObjectServices(neo4jRestUri);

			//create 2 nodes, then get both nodes
			morpheus = this.CreatePerson<MatrixPerson>(NODE1_NAME, NODE1_TITLE);
			neo = this.CreatePerson<MatrixPerson>(NODE2_NAME, NODE2_TITLE);

			//create relationship
			Relationship MtoN = morpheus.CreateRelationshipTo(neo, RelationshipType.Knows);
			Assert.AreEqual(MtoN.StartUri, morpheus.SelfUri);
			Assert.AreEqual(MtoN.EndUri, neo.SelfUri);
			Assert.AreEqual(MtoN.Type, "Knows");

			//add properties on relationship
			MtoN.SetProperty("action", "Recruited Neo");
			MtoN.SetProperty("date", DateTime.Now.ToString());
			nodeObjectServices.SetRelationshipProperties(MtoN);

			//create relationship
			Relationship NtoM = neo.CreateRelationshipTo(morpheus, RelationshipType.Knows);
			Assert.AreEqual(NtoM.StartUri, neo.SelfUri);
			Assert.AreEqual(NtoM.EndUri, morpheus.SelfUri);
			Assert.AreEqual(NtoM.Type, "Knows");

			//add properties on relationship
			NtoM.SetProperty("action", "Recruited By Morpheus");
			NtoM.SetProperty("date", DateTime.Now.ToString());
			nodeObjectServices.SetRelationshipProperties(NtoM);
		}

		private void ValidateRelationshipJson(IEnumerable<Relationship> relationships, int start, int[] ids, RelationshipDirection relDir, IEnumerable<RelationshipType> relTypes)
		{
			Dictionary<string, string> testValues = new Dictionary<string, string>();

			foreach (RelationshipType relType in relTypes)
			{
				switch (relType)
				{
					case RelationshipType.Knows:
						if (relDir == RelationshipDirection.All
							|| (start == ids[0] && relDir == RelationshipDirection.Out)
							|| (start == ids[1] && relDir == RelationshipDirection.In))
						{
							testValues.Add(string.Format("{0}|{1}|Knows", ids[0], ids[1]), "");
						}
						if (relDir == RelationshipDirection.All
							|| (start == ids[1] && relDir == RelationshipDirection.Out)
							|| (start == ids[0] && relDir == RelationshipDirection.In))
						{
							testValues.Add(string.Format("{1}|{0}|Knows", ids[0], ids[1]), "");
						}
						break;
				}
			}

			Assert.AreEqual(relationships.Count(), testValues.Count);
			foreach (var relationship in relationships)
			{
				string startId = relationship.StartUri.Segments[2];
				string endId = relationship.EndUri.Segments[2];
				string action = relationship.Type;
				string key = startId + "|" + endId + "|" + action;
				string[] testData = testValues[key].Split('|');
				//JToken dataToken = token["data"].Value<JToken>();
				//if (testData.Length == 1 && string.IsNullOrWhiteSpace(testData[0]))
				//{
				//    Assert.IsNull(dataToken.First);
				//}
				//else
				//{
				//    Assert.AreEqual(dataToken[testData[0]].Value<string>(), testData[1]);
				//}
			}
		}

        private void ValidatePropertiesOnNode(Person person)
        {
			NodeObjectServices nodeObjectServices = ServicesFactory.ObjectServices(neo4jRestUri);

            //get person properties by id and validate properties against source object
			person.ClearLocalProperties();
            nodeObjectServices.GetNodeProperties(person);
        	
            MatrixPerson mp = person as MatrixPerson;
            if (mp == null)
            {
				Assert.AreEqual(person.GetProperties().Count(), 2);

				Assert.AreEqual(person.GetProperty(MatrixPerson.NAME), person.Name);
                Assert.AreEqual(person.GetProperty(MatrixPerson.TITLE), person.Title);
            }
            else
            {
                Assert.AreEqual(person.GetProperties().Count(), 4);
                Assert.AreEqual(person.GetProperty(MatrixPerson.NAME), mp.Name);
                Assert.AreEqual(person.GetProperty(MatrixPerson.TITLE), mp.Title);
                Assert.AreEqual(person.GetProperty(MatrixPerson.ISHUMAN), mp.IsHuman.ToString());
                Assert.AreEqual(person.GetProperty(MatrixPerson.ISAGENT), mp.IsAgent.ToString());
            }
        }
    }
}
